package www.sharetime.weshare.fragment;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import www.sharetime.weshare.R;
import www.sharetime.weshare.activity.SharePublishActivity;
import www.sharetime.weshare.adapter.HomeFragmentPagerAdapter;
import www.sharetime.weshare.base.BaseFragment;
import www.sharetime.weshare.utils.UIUtils;

/**
 * File Description  : 首页fragment
 *
 * @author : zhanggeng
 * @version : v1.0
 * @email : zhanggengdyx@gmail.com
 * @date : 2017/9/12 19:55
 * **************修订历史*************
 */

public class HomeFragment extends BaseFragment {

    private View mBaseView;

    Unbinder unbinder =null;

    @BindView(R.id.tab_title)
    TabLayout tabTitle;

    @BindView(R.id.home_viewpager)
    ViewPager viewPager;

    @BindView(R.id.img_publish_share)
    ImageView imgPubulish;

    @Override
    public View initView() {
        mBaseView = inflateView(getLayoutId());

        ButterKnife.bind(this, mBaseView);
        return mBaseView;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_home;
    }


    @Override
    public void initData() {
        super.initData();
        viewPager.setAdapter(new HomeFragmentPagerAdapter(getChildFragmentManager(), getActivity()));

        tabTitle.setupWithViewPager(viewPager);
    }

    @OnClick(R.id.img_publish_share)
    public void onViewClick(View view){
        switch (view.getId()){
            case R.id.img_publish_share:
                publishShare();
                break;
            default:
                break;
        }
    }

    /**
     * 发布分享动态
     */
    private void publishShare() {
        UIUtils.startActivity(getActivity() , SharePublishActivity.class);
    }
}
